#ifndef _ENEMY_H
#define _ENEMY_H

#define MAX_ENEMY               100
#define MAX_BALLS               4
#define SCRATCH                 1
#define LOOK                    2

#include <allegro.h>
#include "data.h"
#include "map.h"
#include "globals.h"

//Structs
struct enemy{
    int id;                             //Identifier
    float cur_x,cur_y;                    //x and y position of sprite
    float x1,y1;                          //bounding box
    float x2,y2;                          //bounding box
    int spr;                            //Current sprite
    int alive;                          //Is dead?
    float energy;                         //Amount of energy
    int hit;                            //Enemy hit?
    int dying;                          //is dying?
    int dir;                            //Which direction facing
    int turn;                           //Turned around this time?
    int mov;                            //movement counter
    int mov_max;                        //Move how much
    int mov_dir;                        //Up,Down,Left,Right
    int wait;                           //While stopped how long to wait
    int stop_action;                    //Scratch head or look around
    int shoot;                          //Shooting
    int shoot_count;                    //Shooting Counter
}enemy[MAX_ENEMY],ball[MAX_BALLS];

struct enemy_shot{
    int id;                             //Identifier
    float cur_x,cur_y;
    float x1,x2;
    float y1,y2;
    int spr;
    int alive;
    int glow_count;
    int dir;
}enemy_shot[MAX_ENEMY];  

struct exp{
    int id;
    int x,y;
    int spr;
    int alive;
    int counter;
}enemy_explosion[MAX_ENEMY],ball_explosion[MAX_BALLS];

DATAFILE *enemy_sprites;                        //Data file for enemy sprites
DATAFILE *ball_sprites;                         //Data file for the bouncy ball
DATAFILE *explode_sprites;                      //Data file for explosion


//Decs
void init_enemies(int amount);
void draw_enemies(int amount);
void move_enemies(int amount,float vel);
void enemy_shoot(int amount,int p_x,int p_y);
void update_enemy_shot(int amount,float vel);
void draw_enemy_shot(int amount);
void kill_enemy(int id);
void kill_enemy_shot(int id);
void wipe_enemy(int id);            // Removes the enemy without having to see the animation
void start_enemy_explosion(int id);
void update_enemy_explosion(int amount);
void draw_enemy_explosion(int amount);
void init_ball(int amount,int wait_time);
void draw_ball(int amount);
void move_ball(int amount,float vel,int x,int y);
void kill_ball(int id);
void start_ball_explosion(int id);
void update_ball_explosion(int amount);
void draw_ball_explosion(int amount);
//enemy collisions
int tile_col_enemy(struct TILE t,struct enemy p);
int enemy_col_enemy(struct enemy t,struct enemy p);
int tile_col_enemy_shot( struct TILE t,struct  enemy_shot s);
int enemy_col_enemy_shot(struct enemy t,struct  enemy_shot s);
int enemy_shot_col_enemy_shot(struct enemy_shot t,struct  enemy_shot s);

#endif
